//
//  ActivityViewController.m
//  OrderSeat
//
//  Created by haiming on 13-10-7.
//  Copyright (c) 2013年 wangwei. All rights reserved.
//

#import "ActivityViewController.h"
#import "ActivityView.h"

@implementation ActivityViewController

- (id)init
{
    self = [super initWithNibClass:[ActivityViewController class]];
    if (self) {
        
    }
    return self;
}

- (void)viewDidLoad
{
    [super viewDidLoad];
    [self setupUI];
}

-(void)viewWillAppear:(BOOL)animated
{
    [super viewWillAppear:animated];
    [[AppDelegate sharedInstance] hideTabBar:self.tabBarController];
}

- (void)setupUI
{
    [self createLeftButton];
    [self setNavigationTitle:@"我的活动"];
    
    self.doingActivityView = [self createViewWithType:NewActivity];
}

- (void)leftButtonClick:(id)sender
{
    [self.navigationController popViewControllerAnimated:YES];
    [[AppDelegate sharedInstance] showTabBar:self.tabBarController];
}

- (ActivityView *)createViewWithType:(ActivityType)activityType
{
    CGRect frame = CGRectMake(0, _btnOnGoing.bottom, ScreenWidth, ScreenHeight-_btnOnGoing.bottom);
    ActivityView *activityView  = [[ActivityView alloc] initWithFrame:frame andActivityType:activityType];
    activityView.activityVC = self;
    [self.view addSubview:activityView];
    return activityView;
}

- (IBAction)selAction:(id)sender
{
    _btnOnGoing.selected = _btnExpired.selected = NO;
    UIButton *button = (UIButton*)sender;
    button.selected = !button.selected;
    
    if (!_doingActivityView) self.doingActivityView = [self createViewWithType:NewActivity];
    if (!_doneActivityView) self.doneActivityView = [self createViewWithType:DoneActivity];
    
    _doingActivityView.hidden = !_btnOnGoing.selected;
    _doneActivityView.hidden = !_btnExpired.selected;
}


@end
